
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title> 名医信息创建 </title>
    <link rel="stylesheet" type="text/css" href="/css/style.css" />

    <style type="text/css">
        /*字体样式*/
        *, body {
            margin: 0px;
            font-family: '微软雅黑',serif;
        }
        /*超链接样式*/
        a:link{
            color:red;
        }
        a:visited{
            color:#008000;
        }
        a:active{
            color:cadetblue;
        }
        a:hover{
            color: #a71d5d;
        }
    </style>
    <script src="/js/jquery-1.10.2.min.js"></script>
    <script src="/js/jquery.form.js"></script>
    <script src="/js/generic.js"></script>
</head>

<body>
<table class="maintable">
    <tr>
        <td class="rightmaintd" valign="top">
<!--            返回名医信息页面超链接-->
            <div class="searchdiv">
                <a href="/myxx">&lt; 返回</a>
                <div class="rightsearchdiv"><!-- name --></div>
            </div>
<!--            内容表主体-->
            <table class="leftrighttable" border="0">
                <tr>
                    <td class="lefttdtable" width="50%" valign="top">
                        <table cellpadding="6">
                            <tr>
                                <td class="tdname">名医姓名</td>
                                <td>
                                    <input type="text" id="xingming" class="textinput" maxlength="50">
                                </td>
                            </tr>
                            <tr>
                                <td class="tdname">朝代</td>
                                <td>
                                    <select id="chaodai" class="textselect">
                                        <option value="">请选择</option>
                                        <option value="1979年后">1979年后</option>
                                        <option value="1949-1979年">1949-1979年</option>
                                        <option value="民国">民国</option>
                                        <option value="清">清</option>
                                        <option value="明">明</option>
                                        <option value="元">元</option>
                                        <option value="宋">宋</option>
                                        <option value="隋唐五代">隋唐五代</option>
                                        <option value="魏晋南北朝">魏晋南北朝</option>
                                        <option value="汉">汉</option>
                                        <option value="先秦">先秦</option>
                                        <option value="上古">上古</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td class="tdname">籍贯</td>
                                <td><input type="text" id="jiguan" class="textinput" maxlength="50"></td>
                            </tr>

                            <tr>
                                <td class="tdname">行医地点</td>
                                <td><input type="text" id="xinyididian" class="textinput" maxlength="50"></td>
                            </tr>
                            <tr>
                                <td class="tdname">医家流派</td>
                                <td>
                                    <select id="yijialiupai" class="textselect">
                                        <option value="">请选择</option>
                                        <option value="伤寒派">伤寒派</option>
                                        <option value="脾胃派">脾胃派</option>
                                        <option value="滋阴派">滋阴派</option>
                                        <option value="寒凉派">寒凉派</option>
                                        <option value="温补派">温补派</option>
                                        <option value="温病派">温病派</option>
                                        <option value="火神派">火神派</option>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td class="tdname">特点/备注</td>
                                <td><input type="text" id="tedian" class="textinput" maxlength="50"></td>
                            </tr>
                            <tr>
                                <td class="tdname">师承</td>
                                <td><input type="text" id="shicheng" class="textinput" maxlength="50"></td>
                            </tr>
                            <tr>
                                <td class="tdname">弟子</td>
                                <td><input type="text" id="dizi" class="textinput" maxlength="50"></td>
                            </tr>
                            <tr>
                                <td class="tdname">所在气候</td>
                                <td><input type="text" id="suoshuoqihou" class="textinput" maxlength="50"></td>
                            </tr>

                        </table>
                    </td>
                    <td class="righttdtable" width="50%" valign="top"></td>
                </tr>
            </table>
<!--创建按钮-->
            <div class="shenhediv">
                <input type="button" value="创 &nbsp; &nbsp; 建" class="baocunbtn2" id="Sbutton">
                <span id="lrxx"></span>
            </div>

        </td>
    </tr>
</table>
</body>
</html>
<script type="text/javascript">
    // 保存按钮点击事件处理函数
    var saveButton = document.getElementById('Sbutton');
    saveButton.addEventListener('click',() => {
        // 获取输入框中的数据
        var xingming = document.getElementById('xingming').value;
        if(xingming==""){
            alert("请输入名医姓名！");
            return;
        }
        var chaodai = document.getElementById('chaodai').value;
        if(chaodai=="")
            chaodai=null;
        var jiguan=document.getElementById('jiguan').value;
        if(jiguan=="")
            jiguan=null;
        var xinyididian = document.getElementById('xinyididian').value;
        if(xinyididian=="")
            xinyididian=null;
        var yijialiupai = document.getElementById('yijialiupai').value;
        if(yijialiupai=="")
            yijialiupai=null;
        var tedian = document.getElementById('tedian').value;
        if(tedian=="")
            tedian=null;
        var shicheng=document.getElementById('shicheng').value;
        if(shicheng=="")
            shicheng=null;
        var dizi=document.getElementById('dizi').value;
        if(dizi=="")
            dizi=null;
        var suoshuoqihou=document.getElementById('suoshuoqihou').value;
        if(suoshuoqihou=="")
            suoshuoqihou=null;
        // 创建要发送的数据对象
        var data = {
            xingming: xingming,
            chaodai: chaodai,
            jiguan: jiguan,
            xinyididian: xinyididian,
            yijialiupai: yijialiupai,
            tedian: tedian,
            shicheng: shicheng,
            dizi: dizi,
            suoshuoqihou: suoshuoqihou,
            shenhe: "待审核",
            createuser: "admin"
        };
        // 发送 POST 请求
        var xhr = new XMLHttpRequest();
        xhr.open('POST', '/myxx/', true);
        xhr.setRequestHeader('Content-Type', 'application/json');
        xhr.onreadystatechange = function() {
            if (xhr.readyState === 4 && xhr.status === 200) {
                // 请求完成并成功处理后的回调函数
                console.log('数据已成功发送至后端');
                alert("创建成功！");
                window.location.href="/myxx";
            }
        };
        xhr.send(JSON.stringify(data));
    });

</script>